package Operation;

import Book.Booklist;
import Book.Book;

import java.util.Scanner;

public class borrowBook implements Ioperation{
    @Override
    public void work(Booklist booklist) {
        System.out.println("请输入你要借的书名：");
        Scanner sc=new Scanner(System.in);
        String name=sc.nextLine();
        int size= booklist.getSizeBook();
        for (int i = 0; i <size-1 ; i++) {
            Book book=booklist.getBook(i);
            if (book.getBookName().equals(name)){
                if(book.isBorrow()==true){
                    System.out.println("这本书已经被借出了");
                    break;
                }
                System.out.println("找到了你要借阅的书籍");
                book.setBorrow(true);
                break;
            }else {
                System.out.println("没有找到你的书");
            }
        }

    }

}
